From a6bf63d377755f4667c4e6c92b10a03e8113cc34 Mon Sep 17 00:00:00 2001 From: "gm281@boulderdash.cl.cam.ac.uk" Date: Mon, 2 Aug 2004 11:32:07 +0000 Subject: [PATCH] bitkeeper revision 1.1108.33.26 (410e2637qJ8L22pgeDEMvrnsj5v1_A) BVT fixed to handle wakeups correctly. Min_slice removed --- xen/common/sched_bvt.c | 74 ++++++++++++++++++------------------- xen/common/sched_fair_bvt.c | 3 +- xen/common/sched_rrobin.c | 5 +-- xen/include/xen/sched.h | 1 - 4 files changed, 37 insertions(+), 46 deletions(-) diff --git a/xen/common/sched_bvt.c b/xen/common/sched_bvt.c index 39f45419dd..f83fbf6cc5 100644 --- a/xen/common/sched_bvt.c +++ b/xen/common/sched_bvt.c @@ -91,34 +91,31 @@ static inline int __task_on_runqueue(struct domain *d) return (RUNLIST(d))->next != NULL; } +static inline u32 calc_avt(struct domain *d, s_time_t now) +{ + u32 ranfor, mcus; + struct bvt_dom_info *inf = BVT_INFO(d); + + ranfor = (u32)(now - d->lastschd); + mcus = (ranfor + MCU - 1)/MCU; + + return inf->avt + mcus; +} + + /* * Calculate the effective virtual time for a domain. Take into account * warping limits */ -static void __calc_evt(struct bvt_dom_info *inf) +static inline u32 calc_evt(struct domain *d, u32 avt) { - s_time_t now = NOW(); - + struct bvt_dom_info *inf = BVT_INFO(d); + /* TODO The warp routines need to be rewritten GM */ + if ( inf->warpback ) - { - if ( ((now - inf->warped) < inf->warpl) && - ((now - inf->uwarped) > inf->warpu) ) - { - /* allowed to warp */ - inf->evt = inf->avt - inf->warp; - } - else - { - /* warped for too long -> unwarp */ - inf->evt = inf->avt; - inf->uwarped = now; - inf->warpback = 0; - } - } + return avt - inf->warp; else - { - inf->evt = inf->avt; - } + return avt; } /** @@ -191,8 +188,9 @@ void bvt_wake(struct domain *d) unsigned long flags; struct bvt_dom_info *inf = BVT_INFO(d); struct domain *curr; - s_time_t now, min_time; + s_time_t now, r_time; int cpu = d->processor; + u32 curr_evt; /* The runqueue accesses must be protected */ spin_lock_irqsave(&CPU_INFO(cpu)->run_lock, flags); @@ -215,24 +213,29 @@ void bvt_wake(struct domain *d) inf->avt = CPU_SVT(cpu); /* Deal with warping here. */ - inf->warpback = 1; - inf->warped = now; - __calc_evt(inf); + // TODO rewrite + //inf->warpback = 1; + //inf->warped = now; + inf->evt = calc_evt(d, inf->avt); spin_unlock_irqrestore(&CPU_INFO(cpu)->run_lock, flags); /* Access to schedule_data protected by schedule_lock */ spin_lock_irqsave(&schedule_data[cpu].schedule_lock, flags); curr = schedule_data[cpu].curr; + curr_evt = calc_evt(curr, calc_avt(curr, now)); + /* Calculate the time the current domain would run assuming + the second smallest evt is of the newly woken domain */ + r_time = curr->lastschd + + ((inf->evt - curr_evt) / BVT_INFO(curr)->mcu_advance) + + ctx_allow; - /* Currently-running domain should run at least for ctx_allow. */ - min_time = curr->lastschd + curr->min_slice; spin_unlock_irqrestore(&schedule_data[cpu].schedule_lock, flags); - if ( is_idle_task(curr) || (min_time <= now) ) + if ( is_idle_task(curr) || (inf->evt <= curr_evt) ) cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); - else if ( schedule_data[cpu].s_timer.expires > (min_time + TIME_SLOP) ) - mod_ac_timer(&schedule_data[cpu].s_timer, min_time); + else if ( schedule_data[cpu].s_timer.expires > r_time ) + mod_ac_timer(&schedule_data[cpu].s_timer, r_time); } @@ -360,8 +363,6 @@ static task_slice_t bvt_do_schedule(s_time_t now) struct list_head *tmp; int cpu = prev->processor; s32 r_time; /* time for new dom to run */ - s32 ranfor; /* assume we never run longer than 2.1s! */ - s32 mcus; u32 next_evt, next_prime_evt, min_avt; struct bvt_dom_info *prev_inf = BVT_INFO(prev), *p_inf = NULL, @@ -378,12 +379,8 @@ static task_slice_t bvt_do_schedule(s_time_t now) if ( likely(!is_idle_task(prev)) ) { - ranfor = (s32)(now - prev->lastschd); - /* Calculate mcu and update avt. */ - mcus = (ranfor + MCU - 1) / MCU; - prev_inf->avt += mcus * prev_inf->mcu_advance; - - __calc_evt(prev_inf); + prev_inf->avt = calc_avt(prev, now); + prev_inf->evt = calc_evt(prev, prev_inf->avt); __del_from_runqueue(prev); @@ -493,7 +490,6 @@ static task_slice_t bvt_do_schedule(s_time_t now) ASSERT(r_time >= ctx_allow); sched_done: - next->min_slice = ctx_allow; ret.task = next; ret.time = r_time; return ret; diff --git a/xen/common/sched_fair_bvt.c b/xen/common/sched_fair_bvt.c index 4ecef6183e..05ecc420ea 100644 --- a/xen/common/sched_fair_bvt.c +++ b/xen/common/sched_fair_bvt.c @@ -274,7 +274,7 @@ static void fbvt_wake(struct domain *d) curr = schedule_data[cpu].curr; /* Currently-running domain should run at least for ctx_allow. */ - min_time = curr->lastschd + curr->min_slice; + min_time = curr->lastschd + ctx_allow; spin_unlock_irqrestore(&schedule_data[cpu].schedule_lock, flags); @@ -587,7 +587,6 @@ static task_slice_t fbvt_do_schedule(s_time_t now) sched_done: R_TIME(cpu) = r_time / MCU; TRACE_3D(TRC_SCHED_FBVT_DO_SCHED, next->domain, r_time, LAST_VTB(cpu)); - next->min_slice = ctx_allow; ret.task = next; ret.time = r_time; return ret; diff --git a/xen/common/sched_rrobin.c b/xen/common/sched_rrobin.c index 289816f0b6..b5445b6e97 100644 --- a/xen/common/sched_rrobin.c +++ b/xen/common/sched_rrobin.c @@ -220,10 +220,7 @@ void rr_wake(struct domain *d) curr = schedule_data[cpu].curr; spin_unlock_irqrestore(&schedule_data[cpu].schedule_lock, flags); - /* Currently-running domain should run at least for ctx_allow. */ - min_time = curr->lastschd + curr->min_slice; - - if ( is_idle_task(curr) || (min_time <= now) ) + if ( is_idle_task(curr) ) cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); else if ( schedule_data[cpu].s_timer.expires > (min_time + TIME_SLOP) ) mod_ac_timer(&schedule_data[cpu].s_timer, min_time); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 0dfa5b0606..bb80970724 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -107,7 +107,6 @@ struct domain s_time_t cpu_time; /* total CPU time received till now */ s_time_t wokenup; /* time domain got woken up */ struct ac_timer timer; /* one-shot timer for timeout values */ - s_time_t min_slice; /* minimum time before reschedule */ void *sched_priv; /* scheduler-specific data */ struct mm_struct mm; -- 2.30.2